package com.boot.security.server.controller.mffl.MfflLawfirm;

import com.boot.security.server.model.mffl.MfflLawfirm;
import com.boot.security.server.page.table.PageTableRequest;
import com.boot.security.server.service.impl.mffl.MfflLawfirm.MfflLawfirmService;
import com.boot.security.server.utils.mffl.ReturnBean;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "律所信息")
@RestController
@RequestMapping("client/mfflLawfirms")
public class Client_MfflLawfirmController {

    @Autowired
    private MfflLawfirmService MfflLawfirmService;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id获取")
    public ReturnBean<MfflLawfirm> get(@PathVariable Long id) {
        return MfflLawfirmService.get(id);
    }


    @GetMapping
    @ApiOperation(value = "列表")
    @ApiImplicitParams({
            @ApiImplicitParam(required = true, name = "offset", value = "开始条数", dataType = "int"),
            @ApiImplicitParam(required = true, name = "limit", value = "每页条数", dataType = "int"),
            @ApiImplicitParam(required = false, name = "name", value = "模糊查询名字", paramType = "query"),
            @ApiImplicitParam(required = false, name = "field", value = "擅长领域", paramType = "query",dataType = "int"),
            @ApiImplicitParam(required = false, name = "order", value = "1智能排序排序（order字段，人数，年限无视其他条件） 0取消",  paramType = "query",dataType = "int"),
            @ApiImplicitParam(required = false, name = "city", value = "市级(编码)",  paramType = "query",dataType = "int")})
    public ReturnBean<MfflLawfirm> list(PageTableRequest request) {
        //智能牌排序
        if (request.getParams().containsKey("order")) {
            if (request.getParams().get("order").toString().equals("1")) {
                request.getParams().remove("order");
                request.getParams().put("orderBy", "order by `order`,numberoflawyers,yearsofestablishment ASC");
            }
        }
        return MfflLawfirmService.list(request);
    }
}
